from django.db import models

# Create your models here.
class Department(models.Model):
    '''部门：title,'''
    d_id = models.CharField(max_length=10,verbose_name='部门id')
    title = models.CharField(max_length=10,verbose_name='部门名称')

    class Meta:
        db_table = 't_department'

    def __str__(self):
        return self.title

class UserInfo(models.Model):
    '''员工：name,password,age,account(decimalfield,max_digit,decimal_place,'''
    name = models.CharField(max_length=10,verbose_name='员工姓名')
    password = models.CharField(max_length=10,verbose_name='密码')
    gender_choices = ((1,'男'),(2,'女'))
    gender = models.SmallIntegerField(choices=gender_choices,verbose_name='性别')
    age = models.IntegerField(verbose_name='年龄')
    account = models.DecimalField(max_digits=10,decimal_places=2,verbose_name='账户余额')
    update_time = models.DateTimeField(auto_now=True,verbose_name='更新时间')
    create_time = models.DateField(verbose_name='创建时间')

    department = models.ForeignKey(Department,null=True,blank=True,on_delete=models.SET_NULL,verbose_name='所属部门')

    class Meta:
        db_table = 't_userinfo'

class AdminUser(models.Model):
    '''管理员'''
    username = models.CharField(max_length=16,verbose_name='管理员账户')
    password = models.CharField(max_length=256,verbose_name='管理员密码')
   
    class Meta:
        db_table = 't_adminuser'

